import App from './App'

// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
App.mpType = 'app'
import uView from 'uview-ui'
Vue.use(uView)
//使用rpx
uni.$u.config.unit = 'rpx'

try {
  function isPromise(obj) {
    return (
      !!obj &&
      (typeof obj === "object" || typeof obj === "function") &&
      typeof obj.then === "function"
    );
  }
Vue.prototype.$dtUrl = function() {
  let baseUrl = 'https://api.hc.yitutianxia.com/';
  // let baseUrl = 'https://apitest.yitutianxia.com/images'; //测试
  // let store_id = "5"; //怿途天下APP,与怿途天下小程序共用一个store_id
  // let custId = '4903489';
  // let apikey = 'b8a312b7a4d32f9ef172c8cbce95bcff';
  // let time = String(Date.now() / 1000);
  // let sign = md5(apikey + time);
  return baseUrl
}
// var request = {
//   baseUrl: "http://192.168.0.212:8086/gen",
// };
  // 统一 vue2 API Promise 化返回格式与 vue3 保持一致
  uni.addInterceptor({
    returnValue(res) {
      if (!isPromise(res)) {
        return res;
      }
      return new Promise((resolve, reject) => {
        res.then((res) => {
          if (res[0]) {
            reject(res[0]);
          } else {
            resolve(res[1]);
          }
        });
      });
    },
  });
} catch (error) { }

const app = new Vue({
  ...App
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif